home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / MW MPW Binaries 1.1.1a2 / mwcPPC / MWCIncludes / FragLoad.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-31  |  10.6 KB  |  360 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        FragLoad.h
  3.  
  4.     Copyright:    © 1984-1993 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     WARNING
  7.     This file was auto generated by the interfacer tool. Modifications
  8.     must be made to the master file.
  9.  
  10. */
  11.  
  12. #ifndef __FRAGLOAD__
  13. #define __FRAGLOAD__ 1
  14.  
  15. #ifndef __TYPES__
  16. #include <Types.h>
  17. /*    #include <ConditionalMacros.h>                                */
  18. /*    #include <MixedMode.h>                                        */
  19. /*        #include <Traps.h>                                        */
  20. #endif
  21.  
  22. #ifndef __FILES__
  23. #include <Files.h>
  24. /*    #include <OSUtils.h>                                        */
  25. /*    #include <SegLoad.h>                                        */
  26. #endif
  27.  
  28. #ifndef __TRAPS__
  29. #endif
  30.  
  31. typedef long ConnectionID;
  32.  
  33. typedef unsigned long LoadFlags;
  34.  
  35. typedef unsigned char SymClass;
  36.  
  37. #define kPowerPCArch 'pwpc'
  38.  
  39. #define kMotorola68KArch 'm68k'
  40.  
  41. #define kAnyArchType '???\?'
  42.  
  43.  
  44. // *** Confusing names, soon to be removed!
  45.  
  46. #define kPowerPC 'pwpc'
  47.  
  48. #define kMotorola68K 'm68k'
  49.  
  50. #define kNoLibName ((unsigned char *) 0)
  51.  
  52. #define kNoConnectionID ((ConnectionID) 0)
  53.  
  54. #define kUnresolvedSymbolAddress ((Ptr) 0x0)
  55.  
  56.  
  57. // use for findFlags mask
  58.  
  59. enum  {
  60.     kLoadLib                    = 1,                            // use existing connection if possible
  61.     kFindLib                    = 2,                            // just see if library is already loaded
  62.     kLoadNewCopy                = 5,                            // load a new instance no matter what
  63.     kUseInPlace                    = 0x80                            // use container's sections in place
  64. };
  65.  
  66. enum  {
  67.     kCodeSym                    = 0,
  68.     kDataSym                    = 1,
  69.     kTVectSym                    = 2,
  70.     kTOCSym                        = 3,
  71.     kGlueSym                    = 4
  72. };
  73.  
  74.  
  75. /************************************************************************/
  76.  
  77.  
  78. /*         for fragment initialization routines                         */
  79.  
  80.  
  81. /************************************************************************/
  82.  
  83. #if defined(powerc) || defined (__powerc)
  84. #pragma options align=mac68k
  85. #endif
  86. struct MemFragment {
  87.     Ptr                            address;
  88.     long                        length;
  89.     Boolean                        inPlace;
  90. };
  91. #if defined(powerc) || defined(__powerc)
  92. #pragma options align=reset
  93. #endif
  94.  
  95. typedef struct MemFragment MemFragment;
  96.  
  97. #if defined(powerc) || defined (__powerc)
  98. #pragma options align=mac68k
  99. #endif
  100. struct DiskFragment {
  101.     FSSpecPtr                    fileSpec;                        // ! Must correspond to FSSpecPtr in segmented case!
  102.     long                        offset;
  103.     long                        length;
  104. };
  105. #if defined(powerc) || defined(__powerc)
  106. #pragma options align=reset
  107. #endif
  108.  
  109. typedef struct DiskFragment DiskFragment;
  110.  
  111. #if defined(powerc) || defined (__powerc)
  112. #pragma options align=mac68k
  113. #endif
  114. struct SegmentedFragment {
  115.     FSSpecPtr                    fileSpec;                        // ! Must correspond to FSSpecPtr in data fork case!
  116.     OSType                        rsrcType;
  117.     short                        rsrcID;
  118. };
  119. #if defined(powerc) || defined(__powerc)
  120. #pragma options align=reset
  121. #endif
  122.  
  123. typedef struct SegmentedFragment SegmentedFragment;
  124.  
  125.  
  126. // ! Note that the onDisk and inSegs members are required to have an FSSpecPtr
  127.  
  128.  
  129. // ! field at the same location!  CFM code uses just one member to access the
  130.  
  131.  
  132. // ! information for either case!
  133.  
  134. #if defined(powerc) || defined (__powerc)
  135. #pragma options align=mac68k
  136. #endif
  137. struct FragmentLocator {
  138.     long                        where;
  139.     union {
  140.         MemFragment                    inMem;
  141.         DiskFragment                onDisk;
  142.         SegmentedFragment            inSegs;
  143.     }                            u;
  144. };
  145. #if defined(powerc) || defined(__powerc)
  146. #pragma options align=reset
  147. #endif
  148.  
  149. typedef struct FragmentLocator FragmentLocator, *FragmentLocatorPtr;
  150.  
  151.  
  152. // NOTE: when fragLocator. where == kOnDisk, then
  153.  
  154.  
  155. //       fragLocator. u. onDisk. fileSpec is a pointer
  156.  
  157.  
  158. //       to the file that the library belonged to.
  159.  
  160.  
  161. //       the pointer is valid only for the duration
  162.  
  163.  
  164. //       of the init routine's invocation, so make
  165.  
  166.  
  167. //       a copy of the filespec if it is important
  168.  
  169. #if defined(powerc) || defined (__powerc)
  170. #pragma options align=mac68k
  171. #endif
  172. struct InitBlock {
  173.     long                        contextID;
  174.     long                        closureID;
  175.     long                        connectionID;
  176.     FragmentLocator                fragLocator;
  177.     Ptr                            libName;
  178.     long                        reserved4a;
  179.     long                        reserved4b;
  180.     long                        reserved4c;
  181.     long                        reserved4d;
  182. };
  183. #if defined(powerc) || defined(__powerc)
  184. #pragma options align=reset
  185. #endif
  186.  
  187. typedef struct InitBlock InitBlock, *InitBlockPtr;
  188.  
  189.  
  190. // Prototype for initialization routines.  Note that these are C, not Pascal conventions!
  191.  
  192.  
  193. // This differs from customary "Apple-callback" useage, but is felt to be less error prone
  194.  
  195.  
  196. // in practice since the vast bulk of 68K CFM aware code will be in C.
  197.  
  198.  
  199. // NOTE: Initialization routines may comfortably ignore their parameters, however, they must
  200.  
  201.  
  202. //       return an error status (ie: noErr) in order to succeed with the load of the library.
  203.  
  204.  
  205. // Termination routines get no parameters and have no return value.
  206.  
  207. typedef OSErr ConnectionInitializationRoutine(InitBlockPtr initBlkPtr);
  208.  
  209. typedef void ConnectionTerminationRoutine(void);
  210.  
  211.  
  212. /************************************************************************/
  213.  
  214.  
  215. /*                for building shared libraries                         */
  216.  
  217.  
  218. /************************************************************************/
  219.  
  220. #define kCFMRsrcType 'cfrg'
  221.  
  222. #define kCFMRsrcID 0
  223.  
  224. #define kSHLBFileType 'shlb'
  225.  
  226.  
  227. /************************************************************************/
  228.  
  229.  
  230. /*                error codes                                           */
  231.  
  232.  
  233. /************************************************************************/
  234.  
  235. enum  {
  236.     fragNoErr                    = 0,
  237.     fragContextNotFound            = -2800,                        // contextID was not valid
  238.     fragConnectionIDNotFound    = -2801,                        // connecionID was not valid
  239.     fragSymbolNotFound            = -2802,                        // symbol was not found in connection
  240.     fragSectionNotFound            = -2803,                        // section was not found
  241.     fragLibNotFound                = -2804,                        // library name not found in Frag registry
  242.     fragDupRegLibName            = -2805,                        // registered name already in use
  243.     fragFormatUnknown            = -2806,                        // fragment container format unknown
  244.     fragHadUnresolveds            = -2807,                        // loaded fragment had "hard" unresolved imports
  245.     fragUnused1                    = -2808,                        // unused
  246.     fragNoMem                    = -2809,                        // out of memory for interal bookkeeping
  247.     fragNoAddrSpace                = -2810,                        // out of memory in user's address space for loadable section
  248.     fragNoContextIDs            = -2811,                        // no more context id’s
  249.     fragObjectInitSeqErr        = -2812,                        // order error during user initialization function invocation
  250.     fragImportTooOld            = -2813,                        // import library was too old and therefore incompatible
  251.     fragImportTooNew            = -2814,                        // import library was too new and therefore incompatible
  252.     fragInitLoop                = -2815,                        // circularity detected in mandatory initialization order
  253.     fragInitRtnUsageErr            = -2816,                        // boot library has initialization routine
  254.     fragLibConnErr                = -2817,                        // error connecting to library (error occured in sub prepare)
  255.     fragMgrInitErr                = -2818,                        // error in initailization of this manager
  256.     fragConstErr                = -2819,                        // internal inconstistancy
  257.     fragCorruptErr                = -2820,                        // fragment container corrupted (known format)
  258.     fragUserInitProcErr            = -2821,                        // user intialization routine did not return noErr
  259.     fragAppNotFound                = -2822,                        // no application found in cfrg (for Process Manager)
  260.     fragArchError                = -2823,                        // fragment targeted for an unacceptable architecture
  261.     fragInvalidFragmentUsage    = -2824,                        /* ie: an application's main fragment had no entry point
  262.                                            *    - or - an accerated resource had no entry point,
  263.                                            *               or it had a termination routine, etc... */
  264.     fragLastErrCode                = -2899                            // last reserved error code number
  265. };
  266.  
  267. #if TurnOff68KCFMTraps || __powerc || powerc
  268. #define CFMTrap(arg)
  269.  
  270. #else
  271. #define CFMTrap(arg) = { 0x3F3C, arg, _CodeFragmentDispatch }
  272.  
  273. #endif
  274.  
  275. #ifdef __cplusplus
  276. extern "C" {
  277. #endif
  278.  
  279. extern pascal OSErr GetSharedLibrary(Str63 libName, OSType archType, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
  280.  THREEWORDINLINE(0x3F3C, 1, 0xAA5A);
  281. #define GetSharedLibraryProcInfo  \
  282.     (kPascalStackBased    |            \
  283.     RESULT_SIZE(kTwoByteCode) |     \
  284.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  285.     STACK_ROUTINE_PARAMETER(2, kFourByteCode) |     \
  286.     STACK_ROUTINE_PARAMETER(3, kFourByteCode) |     \
  287.     STACK_ROUTINE_PARAMETER(4, kFourByteCode) |     \
  288.     STACK_ROUTINE_PARAMETER(5, kFourByteCode) |     \
  289.     STACK_ROUTINE_PARAMETER(6, kFourByteCode))
  290.  
  291. extern pascal OSErr GetDiskFragment(FSSpecPtr fileSpec, long offset, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
  292.  THREEWORDINLINE(0x3F3C, 2, 0xAA5A);
  293. #define GetDiskFragmentProcInfo  \
  294.     (kPascalStackBased    |            \
  295.     RESULT_SIZE(kTwoByteCode) |     \
  296.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  297.     STACK_ROUTINE_PARAMETER(2, kFourByteCode) |     \
  298.     STACK_ROUTINE_PARAMETER(3, kFourByteCode) |     \
  299.     STACK_ROUTINE_PARAMETER(4, kFourByteCode) |     \
  300.     STACK_ROUTINE_PARAMETER(5, kFourByteCode) |     \
  301.     STACK_ROUTINE_PARAMETER(6, kFourByteCode) |     \
  302.     STACK_ROUTINE_PARAMETER(7, kFourByteCode) |     \
  303.     STACK_ROUTINE_PARAMETER(8, kFourByteCode))
  304.  
  305. extern pascal OSErr GetMemFragment(Ptr memAddr, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
  306.  THREEWORDINLINE(0x3F3C, 3, 0xAA5A);
  307. #define GetMemFragmentProcInfo     \
  308.     (kPascalStackBased    |            \
  309.     RESULT_SIZE(kTwoByteCode) |     \
  310.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  311.     STACK_ROUTINE_PARAMETER(2, kFourByteCode) |     \
  312.     STACK_ROUTINE_PARAMETER(3, kFourByteCode) |     \
  313.     STACK_ROUTINE_PARAMETER(4, kFourByteCode) |     \
  314.     STACK_ROUTINE_PARAMETER(5, kFourByteCode) |     \
  315.     STACK_ROUTINE_PARAMETER(6, kFourByteCode) |     \
  316.     STACK_ROUTINE_PARAMETER(7, kFourByteCode))
  317.  
  318. extern pascal OSErr CloseConnection(ConnectionID *connID)
  319.  THREEWORDINLINE(0x3F3C, 4, 0xAA5A);
  320. #define CloseConnectionProcInfo  \
  321.     (kPascalStackBased    |            \
  322.     RESULT_SIZE(kTwoByteCode) |     \
  323.     STACK_ROUTINE_PARAMETER(1, kFourByteCode))
  324.  
  325. extern pascal OSErr FindSymbol(ConnectionID connID, Str255 symName, Ptr *symAddr, SymClass *symClass)
  326.  THREEWORDINLINE(0x3F3C, 5, 0xAA5A);
  327. #define FindSymbolProcInfo         \
  328.     (kPascalStackBased    |            \
  329.     RESULT_SIZE(kTwoByteCode) |     \
  330.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  331.     STACK_ROUTINE_PARAMETER(2, kFourByteCode) |     \
  332.     STACK_ROUTINE_PARAMETER(3, kFourByteCode) |     \
  333.     STACK_ROUTINE_PARAMETER(4, kFourByteCode))
  334.  
  335. extern pascal OSErr CountSymbols(ConnectionID connID, long *symCount)
  336.  THREEWORDINLINE(0x3F3C, 6, 0xAA5A);
  337. #define CountSymbolsProcInfo     \
  338.     (kPascalStackBased    |            \
  339.     RESULT_SIZE(kTwoByteCode) |     \
  340.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  341.     STACK_ROUTINE_PARAMETER(2, kFourByteCode))
  342.  
  343. extern pascal OSErr GetIndSymbol(ConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, SymClass *symClass)
  344.  THREEWORDINLINE(0x3F3C, 7, 0xAA5A);
  345. #define GetIndSymbolProcInfo     \
  346.     (kPascalStackBased    |            \
  347.     RESULT_SIZE(kTwoByteCode) |     \
  348.     STACK_ROUTINE_PARAMETER(1, kFourByteCode) |     \
  349.     STACK_ROUTINE_PARAMETER(2, kFourByteCode) |     \
  350.     STACK_ROUTINE_PARAMETER(3, kFourByteCode) |     \
  351.     STACK_ROUTINE_PARAMETER(4, kFourByteCode) |     \
  352.     STACK_ROUTINE_PARAMETER(5, kFourByteCode))
  353.  
  354. #ifdef __cplusplus
  355. }
  356. #endif
  357.  
  358. #endif
  359.  
  360.